/*
 * $Id$
 */
package py.firefly;

import py.firefly.request.HttpMethod;

/**
 *
 * @author myang
 */
public class Route {
    private HttpMethod _httpMethod;
    private String _path;
    private Handler _handler;

    public static Route GET(final String path, final Handler handler) {
        return new Route(HttpMethod.GET, path, handler);
    }

    public static Route POST(final String path, final Handler handler) {
        return new Route(HttpMethod.POST, path, handler);
    }

    private Route(final HttpMethod method, final String path, final Handler handler) {
        _httpMethod = method;
        _path = path;
        _handler = handler;
    }

    /**
     * 
     * @param method
     * @return 
     */
    public boolean accepts(final HttpMethod method) {
        return _httpMethod == method;
    }

    /**
     * 
     * @return 
     */
    public String path() {
        return _path;
    }

    /**
     * 
     * @return 
     */
    public Handler handler() {
        return _handler;
    }
}
